<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>PortChannel (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>

  <script type="text/javascript" src="//www.google.com/jsapi"></script>
  <script type="text/javascript">
     google.load("visualization", "1", {packages:["orgchart"]});
     var _loadingVisualizations = true;
  </script>

  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">messaging.PortChannel</span>
        <span>Extends</span>
        <span class="fn-name">
          <a href="class_goog_messaging_AbstractChannel.html">
          goog.messaging.AbstractChannel
</a>
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    A wrapper for several types of HTML5 message-passing entities
(<code> MessagePort</code>s and <code> WebWorker</code>s). This class implements the
<code> goog.messaging.MessageChannel</code> interface.

This class can be used in conjunction with other communication on the port.
It sets <code> goog.messaging.PortChannel.FLAG</code> to true on all messages it
sends.


  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_messaging_portchannel.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/messaging/portchannel.js">Git</a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
  <tr><td><span class="type"><a href="class_goog_Disposable.html">goog.Disposable</a></span></td><td></td></tr>
  <tr><td><span class="type"><a href="class_goog_messaging_AbstractChannel.html">goog.messaging.AbstractChannel</a></span></td><td><span class="type"><a href="class_goog_Disposable.html">goog.Disposable</a></span></td></tr>
  <tr><td>goog.messaging.PortChannel</td><td><span class="type"><a href="class_goog_messaging_AbstractChannel.html">goog.messaging.AbstractChannel</a></span></td></tr>
</table>
</div>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
</table>
</div>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.messaging.PortChannel(<span><span class="arg">underlyingPort</span></span>)
  </div>

   <h3>Parameters</h3>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">underlyingPort</span>
        : <span>!</span><span class="type">MessagePort</span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type">WebWorker</span>
        <div class="entryOverview">The message-passing
    entity to wrap. If this is a <code> MessagePort</code>, it should be started.
    The remote end should also be wrapped in a PortChannel. This will be
    disposed along with the PortChannel; this means terminating it if it's a
    worker or removing it from the DOM if it's an iframe.</div>
     </td>
   </tr>
  </table>


<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_messaging_PortChannel.html">
              goog.messaging.PortChannel
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.prototype.deliver_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">deliver_<span class="args">(<span class="arg">e</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Delivers a message to the appropriate service handler. If this message isn't
a GearsWorkerChannel message, it's ignored and passed on to other handlers.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">e</span>
        : <span class="type"><a href="class_goog_events_Event.html">goog.events.Event</a></span>
        <div class="entryOverview">The event.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line264">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.prototype.disposeInternal"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">disposeInternal<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line390">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.prototype.extractPorts_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">extractPorts_<span class="args">(<span class="arg">ports</span>,&nbsp;<span class="arg">message</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
      </div>


     <div class="entryOverview">
       Extracts all MessagePort objects from a message to be sent into an array.

The message ports are replaced by placeholder objects that will be replaced
with the ports again on the other side of the channel.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">ports</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type">MessagePort</span>&gt;
        <div class="entryOverview">The array that will contain ports
    extracted from the message. Will be destructively modified. Should be
    empty initially.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">message</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The message from which ports will be
    extracted.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>&nbsp;
            The message with ports extracted.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line340">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.prototype.injectPorts_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">injectPorts_<span class="args">(<span class="arg">ports</span>,&nbsp;<span class="arg">message</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
      </div>


     <div class="entryOverview">
       Injects MessagePorts back into a message received from across the channel.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">ports</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type">MessagePort</span>&gt;
        <div class="entryOverview">The array of ports to be injected into the
    message.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">message</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The message into which the ports will be
    injected.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>&nbsp;
            The message with ports injected.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line372">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.prototype.send"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">send<span class="args">(<span class="arg">serviceName</span>,&nbsp;<span class="arg">payload</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Sends a message over the channel.

As an addition to the basic MessageChannel send API, PortChannels can send
objects that contain MessagePorts. Note that only plain Objects and Arrays,
not their subclasses, can contain MessagePorts.

As per <code> <a href="http://www.w3.org/TR/html5/comms.html#clone-a-port">http://www.w3.org/TR/html5/comms.html#clone-a-port</a></code>, once a
port is copied to be sent across a channel, the original port will cease
being able to send or receive messages.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">serviceName</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The name of the service this message should be
    delivered to.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">payload</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type">MessagePort</span>
        <div class="entryOverview">The value of the message. May
    contain MessagePorts or be a MessagePort.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line243">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.prototype.validateMessage_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">validateMessage_<span class="args">(<span class="arg">data</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Checks whether the message is invalid in some way.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">data</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The contents of the message.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            True if the message is valid, false otherwise.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line307">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_messaging_AbstractChannel.html">
              goog.messaging.AbstractChannel
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.AbstractChannel.prototype.connect"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">connect<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Immediately calls opt_connectCb if given, and is otherwise a no-op. If
subclasses have configuration that needs to happen before the channel is
connected, they should override this and <code> #isConnected</code>.

     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line79">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry protected">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.AbstractChannel.prototype.decodePayload"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">decodePayload<span class="args">(<span class="arg">serviceName</span>,&nbsp;<span class="arg">payload</span>,&nbsp;<span class="arg">objectPayload</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
      </div>


     <div class="entryOverview">
       Converts the message payload into the format expected by the registered
service (either JSON or string).


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">serviceName</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The name of the service receiving the message.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">payload</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The contents of the message.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">objectPayload</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
        <div class="entryOverview">Whether the service expects an object or a
    plain string.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>&nbsp;
            The payload in the format expected by the service, or
    null if something went wrong.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line186">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.AbstractChannel.prototype.defaultService_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">defaultService_<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       The default service to be run when no other services match.


     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line61">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry protected">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.AbstractChannel.prototype.deliver"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">deliver<span class="args">(<span class="arg">serviceName</span>,&nbsp;<span class="arg">payload</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Delivers a message to the appropriate service. This is meant to be called by
subclasses when they receive messages.

This method takes into account both explicitly-registered and default
services, as well as making sure that JSON payloads are decoded when
necessary. If the subclass is capable of passing objects as payloads, those
objects can be passed in to this method directly. Otherwise, the (potentially
JSON-encoded) strings should be passed in.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">serviceName</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The name of the service receiving the message.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">payload</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The contents of the message.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line132">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.AbstractChannel.prototype.disposeInternal"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">disposeInternal<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line205">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry protected">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.AbstractChannel.prototype.getService"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getService<span class="args">(<span class="arg">serviceName</span>,&nbsp;<span class="arg">payload</span>)</span>
        </span>
        &#8658; <span>?</span><span class="type">{callback: function((string</span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type">Object)), objectPayload: boolean</span>
      </div>


     <div class="entryOverview">
       Find the service object for a given service name. If there's no service
explicitly registered, but there is a default service, a service object is
constructed for it.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">serviceName</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The name of the service receiving the message.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">payload</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The contents of the message.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>?</span><span class="type">{callback: function((string</span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type">Object)), objectPayload: boolean</span>&nbsp;
            } The
    service object for the given service, or null if none was found.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line158">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.AbstractChannel.prototype.isConnected"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">isConnected<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Always returns true. If subclasses have configuration that needs to happen
before the channel is connected, they should override this and
<code> #connect</code>.

     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line92">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.AbstractChannel.prototype.registerDefaultService"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">registerDefaultService<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line108">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.AbstractChannel.prototype.registerService"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">registerService<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line98">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_Disposable.html">
              goog.Disposable
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.Disposable.prototype.addOnDisposeCallback"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">addOnDisposeCallback<span class="args">(<span class="arg">callback</span>,&nbsp;<span class="arg">opt_scope</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Invokes a callback function when this object is disposed. Callbacks are
invoked in the order in which they were added.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">callback</span>
        : <span class="type">function(this:T</span>)<span>:?</span>
        <div class="entryOverview">The callback function.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_scope</span>
        : <span class="type">T=</span>
        <div class="entryOverview">An optional scope to call the callback in.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line211">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.Disposable.prototype.dispose"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">dispose<span class="args">()</span>
        </span>
        &#8658; <span class="type">void</span>
      </div>


     <div class="entryOverview">
       Disposes of the object. If the object hasn't already been disposed of, calls
<code> #disposeInternal</code>. Classes that extend <code> goog.Disposable</code> should
override <code> #disposeInternal</code> in order to delete references to COM
objects, DOM nodes, and other disposable objects. Reentrant.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type">void</span>&nbsp;
            Nothing.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line172">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry protected">
       <td class="access"></td>






  <td>
    <a name="goog.Disposable.prototype.disposeInternal"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">disposeInternal<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Deletes or nulls out any references to COM objects, DOM nodes, or other
disposable objects. Classes that extend <code> goog.Disposable</code> should
override this method.
Not reentrant. To avoid calling it twice, it must only be called from the
subclass' <code> disposeInternal</code> method. Everywhere else the public
<code> dispose</code> method must be used.
For example:
<pre class="lang-js prettyprint">
  mypackage.MyClass = function() {
    goog.base(this);
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    goog.base(this, 'disposeInternal');
  };
</pre>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line245">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td class="deprecated">
    <a name="goog.Disposable.prototype.getDisposed"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getDisposed<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       <span class="deprecatedMessage">Use <code> #isDisposed</code> instead.</span>
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            Whether the object has been disposed of.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line160">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.Disposable.prototype.isDisposed"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">isDisposed<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            Whether the object has been disposed of.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line151">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.Disposable.prototype.registerDisposable"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">registerDisposable<span class="args">(<span class="arg">disposable</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Associates a disposable object with this object so that they will be disposed
together.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">disposable</span>
        : <span class="type"><a href="interface_goog_disposable_IDisposable.html">goog.disposable.IDisposable</a></span>
        <div class="entryOverview">that will be disposed when
    this object is disposed.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line199">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Instance Properties</h2>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_messaging_PortChannel.html">
              goog.messaging.PortChannel
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.messaging.PortChannel.prototype.constructor"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">constructor</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line64">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.messaging.PortChannel.prototype.listenerKey_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">listenerKey_</span>
        : 
     </div>


     <div class="entryOverview">
       The key for the event listener.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line79">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry protected">
       <td class="access"></td>





  <a name="goog.messaging.PortChannel.prototype.logger"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">logger</span>
        : <span class="type"><a href="class_goog_debug_Logger.html">goog.debug.Logger</a></span>
     </div>


     <div class="entryOverview">
       Logger for this class.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line222">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.messaging.PortChannel.prototype.port_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">port_</span>
        : 
     </div>


     <div class="entryOverview">
       The wrapped message-passing entity.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line72">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_messaging_AbstractChannel.html">
              goog.messaging.AbstractChannel
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.messaging.AbstractChannel.prototype.constructor"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">constructor</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line41">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry protected">
       <td class="access"></td>





  <a name="goog.messaging.AbstractChannel.prototype.logger"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">logger</span>
        : <span class="type"><a href="class_goog_debug_Logger.html">goog.debug.Logger</a></span>
     </div>


     <div class="entryOverview">
       Logger for this class.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line69">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.messaging.AbstractChannel.prototype.send"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">send</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line115">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.messaging.AbstractChannel.prototype.services_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">services_</span>
        : 
     </div>


     <div class="entryOverview">
       The services registered for this channel.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_abstractchannel.js.source.html#line50">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_Disposable.html">
              goog.Disposable
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.Disposable.prototype.creationStack"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">creationStack</span>
        : 
     </div>


     <div class="entryOverview">
       If monitoring the goog.Disposable instances is enabled, stores the creation
stack trace of the Disposable instance.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line144">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.Disposable.prototype.disposed_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">disposed_</span>
        : 
     </div>


     <div class="entryOverview">
       Whether the object has been disposed of.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line128">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.Disposable.prototype.onDisposeCallbacks_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">onDisposeCallbacks_</span>
        : 
     </div>


     <div class="entryOverview">
       Callbacks to invoke when this object is disposed.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line136">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Static Methods</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.forEmbeddedWindow"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.messaging.PortChannel.</span><span class="entryName">forEmbeddedWindow<span class="args">(<span class="arg">window</span>,&nbsp;<span class="arg">peerOrigin</span>,&nbsp;<span class="arg">opt_timer</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_messaging_DeferredChannel.html">goog.messaging.DeferredChannel</a></span>
      </div>


     <div class="entryOverview">
       Create a PortChannel that communicates with a window embedded in the current
page (e.g. an iframe contentWindow). The code within the window should call
<code> forGlobalWindow</code> to establish the connection.

It's possible to use this channel in conjunction with other messages to the
embedded window. However, only one PortChannel should be used for a given
window at a time.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">window</span>
        : <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/DOM/window">Window</a></span>
        <div class="entryOverview">The window object to communicate with.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">peerOrigin</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The expected origin of the window. See
    <a href="http://dev.w3.org/html5/postmsg/#dom-window-postmessage">http://dev.w3.org/html5/postmsg/#dom-window-postmessage</a>.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_timer</span>
        : <span class="type">goog.Timer=</span>
        <div class="entryOverview">The timer that regulates how often the initial
    connection message is attempted. This will be automatically disposed once
    the connection is established, or when the connection is cancelled.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_messaging_DeferredChannel.html">goog.messaging.DeferredChannel</a></span>&nbsp;
            The PortChannel. Although this is
    not actually an instance of the PortChannel class, it will behave like
    one in that MessagePorts may be sent across it. The DeferredChannel may
    be cancelled before a connection is established in order to abort the
    attempt to make a connection.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line106">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.forGlobalWindow"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.messaging.PortChannel.</span><span class="entryName">forGlobalWindow<span class="args">(<span class="arg">peerOrigin</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="interface_goog_messaging_MessageChannel.html">goog.messaging.MessageChannel</a></span>
      </div>


     <div class="entryOverview">
       Create a PortChannel that communicates with the document in which this window
is embedded (e.g. within an iframe). The enclosing document should call
<code> forEmbeddedWindow</code> to establish the connection.

It's possible to use this channel in conjunction with other messages posted
to the global window. However, only one PortChannel should be used for the
global window at a time.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">peerOrigin</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The expected origin of the enclosing document. See
    <a href="http://dev.w3.org/html5/postmsg/#dom-window-postmessage">http://dev.w3.org/html5/postmsg/#dom-window-postmessage</a>.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="interface_goog_messaging_MessageChannel.html">goog.messaging.MessageChannel</a></span>&nbsp;
            The PortChannel. Although this may
    not actually be an instance of the PortChannel class, it will behave like
    one in that MessagePorts may be sent across it.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line165">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



<h2>Static Properties</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.messaging.PortChannel.FLAG"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.messaging.PortChannel.</span><span class="entryName">FLAG</span>
        : 
     </div>


     <div class="entryOverview">
       The flag added to messages that are sent by a PortChannel, and are meant to
be handled by one on the other side.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line199">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.messaging.PortChannel.REQUIRES_SERIALIZATION_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.messaging.PortChannel.</span><span class="entryName">REQUIRES_SERIALIZATION_</span>
        : 
     </div>


     <div class="entryOverview">
       Whether the messages sent across the channel must be JSON-serialized. This is
required for older versions of Webkit, which can only send string messages.

Although Safari and Chrome have separate implementations of message passing,
both of them support passing objects by Webkit 533.


     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line212">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.messaging.PortChannel.superClass_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.messaging.PortChannel.</span><span class="entryName">superClass_</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line64">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package messaging</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="messaging.PortChannel"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
